﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Caching;
using System.Globalization;
using Microsoft.Practices.EnterpriseLibrary.Caching.Expirations;

namespace Barbar.MapReport.HtmlRender {
  internal static class HtmlRenderCacheManager {
    public static void AddCallbackItem(string callbackId, MapCallbackService service, object value) {
      CacheManager manager = CacheFactory.GetCacheManager();
      string key = String.Format(CultureInfo.InvariantCulture, "{0}:{1}", callbackId, service.GetType().FullName);
      manager.Add(key, value, CacheItemPriority.Normal, null, new AbsoluteTime(new TimeSpan(0, 20, 0)));
    }

    public static object GetCallbackItem(string callbackId, string callbackService) {
      CacheManager manager = CacheFactory.GetCacheManager();
      string key = String.Format(CultureInfo.InvariantCulture, "{0}:{1}", callbackId, callbackService);
      return manager[key];
    }
  }
}
